/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-07-23
 * Time: 22:20
 */
class Solution13 {
    public int longestPalindrome(String s) {
        int n = s.length();
        //1.计数 —— 用数组模拟哈希表
        int[] hash = new int[127];
        for(int i = 0; i < n; i++) {
            hash[s.charAt(i)]++;
        }
        //2.统计结果
        int ret = 0;

        for(int x : hash) {
            ret += x / 2 * 2;
        }

        return ret < n ? ret+1 : ret;
    }
}
